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