Update README.md
This commit is contained in:
parent
f390935bea
commit
3f303c4539
95
README.md
95
README.md
|
@ -12,20 +12,20 @@ See [https://wiki.openstreetmap.org/wiki/Salem_Oregon_Address_Import](https://wi
|
|||
|
||||
## Field Mapping
|
||||
|
||||
- ADD_NUM -> addr:housenumber
|
||||
- FULL_ST_NA -> addr:street via getformattedstreetname(FULL_ST_NA)
|
||||
- SUB_VAL -> addr:unit
|
||||
- CITY -> addr:city via title(CITY)
|
||||
- ZIP -> addr:postcode
|
||||
|
||||
- manually add addr:state "OR"
|
||||
- ADD_NUM -> addr:housenumber (int)
|
||||
- formatstreet(FULL_ST_NAME) -> addr:street (text)
|
||||
- SUB_VAL -> addr:unit (text)
|
||||
- title(CITY) -> addr:city (text)
|
||||
- ZIP -> addr:postcode (text)
|
||||
- addr:state 'OR' (manually added)
|
||||
|
||||
## Processing
|
||||
|
||||
- Use the below script in QGIS to do virtual field calculations.
|
||||
- Export the layer to geojson with WGS84 projection.
|
||||
- Get `Primary_Addresses.geojson` from the City GIS server linked above.
|
||||
- Open the file in QGIS and open the layer attribute table
|
||||
- Use the field calculator and the below script to add new virtual fields per the mapping above.
|
||||
- Export the layer to geojson with "EPSG:4326 - WGS 84" projection. Deselect all fields besides those above.
|
||||
- Save as `processed.geojson`
|
||||
- Use VIM or similar to find-replace "ADD_NUM" to "addr:housenumber" etc.
|
||||
|
||||
## Import steps
|
||||
|
||||
|
@ -52,45 +52,40 @@ source:url=https://data.cityofsalem.net/datasets/salem::primary-address/explore
|
|||
## QGIS Processing script
|
||||
|
||||
```
|
||||
from qgis.core import *
|
||||
from qgis.gui import *
|
||||
import qgis.core
|
||||
import qgis.gui
|
||||
import re
|
||||
|
||||
@qgsfunction(args='auto', group='Custom', referenced_columns=[])
|
||||
def getformattedstreetname(value1, feature, parent):
|
||||
parts = value1.split()
|
||||
parts = map(formatstreetname, parts)
|
||||
return " ".join(parts)
|
||||
#
|
||||
# This will keep street names like SR 574A as SR 574A however
|
||||
# will lowercase other number-digit suffixes with <2 or >4 numbers
|
||||
# or >1 suffix-letters, like 12th Street or 243rd Ave.
|
||||
#
|
||||
|
||||
@qgsfunction(args='auto', group='Custom', referenced_columns=[])
|
||||
def getformattedstreetnamefromaddress(value1, feature, parent):
|
||||
def getstreetfromaddress(value1, feature, parent):
|
||||
parts = value1.split()
|
||||
parts.pop(0) # Ignore the first bit (i.e. "123" in "123 N MAIN ST")
|
||||
parts = map(formatstreetname, parts)
|
||||
return " ".join(parts)
|
||||
|
||||
@qgsfunction(args='auto', group='Custom', referenced_columns=[])
|
||||
def formatstreet(value1, feature, parent):
|
||||
parts = value1.split()
|
||||
parts = map(formatstreetname, parts)
|
||||
return " ".join(parts)
|
||||
|
||||
# Internal function
|
||||
def formatstreetname(name):
|
||||
# Specific suffixes like "123th" we have lower
|
||||
if re.search("[0-9]+TH", name):
|
||||
return name.capitalize()
|
||||
if re.search("[0-9]+ND", name):
|
||||
return name.capitalize()
|
||||
if re.search("[0-9]+ST", name):
|
||||
return name.capitalize()
|
||||
if re.search("[0-9]+RD", name):
|
||||
return name.capitalize()
|
||||
# Weird names like 123D we keep upper
|
||||
if re.search("[0-9]+[A-Z]+", name):
|
||||
return name
|
||||
# Prefixes we want to keep uppercase
|
||||
# Acryonyms
|
||||
if name == "CR":
|
||||
return "County Road"
|
||||
if name == "SR":
|
||||
return "SR" # State Route
|
||||
if name == "NFS":
|
||||
return "NFS" # National Forest Service?
|
||||
if name == "US":
|
||||
return "US"
|
||||
if name == "SR":
|
||||
return "SR"
|
||||
if name == "CR":
|
||||
return "CR"
|
||||
if name == "C":
|
||||
return "C"
|
||||
# Directions
|
||||
if name == "N":
|
||||
return "North"
|
||||
|
@ -109,8 +104,6 @@ def formatstreetname(name):
|
|||
if name == "NW":
|
||||
return "Northwest"
|
||||
# Suffixes
|
||||
if name == "AV":
|
||||
return "Avenue"
|
||||
if name == "AVE":
|
||||
return "Avenue"
|
||||
if name == "BLVD":
|
||||
|
@ -119,6 +112,8 @@ def formatstreetname(name):
|
|||
return "Bend"
|
||||
if name == "CIR":
|
||||
return "Circle"
|
||||
if name == "CR":
|
||||
return "Circle"
|
||||
if name == "CT":
|
||||
return "Court"
|
||||
if name == "DR":
|
||||
|
@ -127,18 +122,18 @@ def formatstreetname(name):
|
|||
return "Fields"
|
||||
if name == "GRV":
|
||||
return "Grove"
|
||||
if name == "HL":
|
||||
return "Hill"
|
||||
if name == "HOLW":
|
||||
return "Hollow"
|
||||
if name == "HW":
|
||||
return "Highway"
|
||||
if name == "HWY":
|
||||
return "Highway"
|
||||
if name == "LN":
|
||||
return "Lane"
|
||||
if name == "LP":
|
||||
return "Loop"
|
||||
if name == "LOOP":
|
||||
return "Loop"
|
||||
if name == "LP":
|
||||
return "Loop"
|
||||
if name == "PATH":
|
||||
return "Path"
|
||||
if name == "PL":
|
||||
|
@ -147,24 +142,24 @@ def formatstreetname(name):
|
|||
return "Road"
|
||||
if name == "RUN":
|
||||
return "Run"
|
||||
if name == "SQ":
|
||||
return "Square"
|
||||
if name == "ST":
|
||||
return "Street"
|
||||
if name == "TER":
|
||||
return "Terrace"
|
||||
if name == "TL":
|
||||
return "Trail"
|
||||
if name == "TRL":
|
||||
return "Trail"
|
||||
if name == "VW":
|
||||
return "View"
|
||||
if name == "WAY":
|
||||
return "Way"
|
||||
if name == "WY":
|
||||
return "Way"
|
||||
if name == "XING":
|
||||
return "Crossing"
|
||||
# Irish names
|
||||
if name == "MCCRAY":
|
||||
return "McCray"
|
||||
if name == "MCKOWN":
|
||||
return "McKown"
|
||||
if re.match('^[0-9]{2,4}[A-Za-z]$', name) != None:
|
||||
return name
|
||||
|
||||
return name.capitalize()
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue
Block a user