Skip to content

NPM script to generate latitude and longitude lines in GeoJSON format

License

Notifications You must be signed in to change notification settings

roblabs/make-latitude-longitude-lines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Make Latitude & Longitude Lines

NPM script to generate latitude and longitude lines in GeoJSON format

Usage

# do this once
npm install --global
# npm uninstall --global

makeLatitudeLongitudeLines

# or if you want to install to the current folder
npm install
./cli.js

#

Generates GeoJSON that looks like this

// This example draws lines every 2.5 minutes
{
  "type": "Feature",
  "properties": {
    "wgs84Degrees": "32° 50' 00\" N",
    "wgs84Decimal": "32.833333"
  },
  "geometry": {"type":"LineString","coordinates":[[-180,32.833333],[180,32.833333]]      }
},
{
  "type": "Feature",
  "properties": {
    "wgs84Degrees": "32° 52' 30\" N",
    "wgs84Decimal": "32.875000"
  },
  "geometry": {"type":"LineString","coordinates":[[-180,32.875],[180,32.875]]      }
}
makeLatitudeLongitudeLines > 2.5minutes.geojson

# convert to ESRI Shapefile
ogr2ogr -f "ESRI Shapefile" 2.5minutes.shp 2.5minutes.geojson

# clip to San Diego
BBOX="-117.34573 32.52852 -116.57119 33.05149"
ogr2ogr \
  -t_srs EPSG:4326 \
  -clipdst $BBOX \
  -f GeoJSON sandiego.geojson 2.5minutes.geojson

Examples

  • Black Latitude & Longitude lines every 2.5 minutes



Filter the GeoJSON and just use the lines that cross at Null Island.

# use `makeLatitudeLongitudeLines` instead of `cli.js` if you installed as global

# Generate
./cli.js > out.geojson

# Convert to ndjson
cat out.geojson | geojson2ndjson > out.ndjson

# filter and keep certain  properties
ndjson-filter < out.ndjson 'd.properties.wgs84Decimal == "0.000000"' > null-island-grid.ndjson

# merge a stream into a feature collection
ndjson-reduce < null-island-grid.ndjson 'p.features.push(d), p' '{type: "FeatureCollection", features: []}' > null-island-grid.geojson

# view at geojson.io
geojsonio null-island-grid.geojson



# or, as a one-liner

cat out.geojson | \
  geojson2ndjson | \
  ndjson-filter 'd.properties.wgs84Decimal == "0.000000"' | \
  ndjson-reduce 'p.features.push(d), p' '{type: "FeatureCollection", features: []}'


References

About

NPM script to generate latitude and longitude lines in GeoJSON format

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published