Skip to content

Instantly share code, notes, and snippets.

@johnwbryant
Last active September 17, 2024 01:18
Show Gist options
  • Save johnwbryant/06b504e2cfb4044c5216a1627ccc6180 to your computer and use it in GitHub Desktop.
Save johnwbryant/06b504e2cfb4044c5216a1627ccc6180 to your computer and use it in GitHub Desktop.
Extract Australia data in a usable format from Microsoft road detections data
#!/bin/bash
# see https://github.com/microsoft/RoadDetections
# 1) get the data
wget https://usaminedroads.blob.core.windows.net/road-detections/Oceania-Full.zip
# 2) extract the records for Australia, second column of tsv only
zgrep AUS Oceania-Full.zip | cut -f2 > AUS.geojson
# 3) convert to GPKG, works better in QGIS
ogr2ogr -f GPKG Oceania_AUS.gpkg AUS.geojson
@kirkeN
Copy link

kirkeN commented Dec 30, 2022

#PowerShell

# 1) get the data
curl.exe -O https://usaminedroads.blob.core.windows.net/road-detections/Europe-Full.zip

# 2) extract the records for Estonia, second column of tsv only
Expand-Archive Europe-Full.zip
Select-String -Path Europe-Full\Europe-Full.tsv -Pattern 'EST' -CaseSensitive |  ForEach-Object { ([string]$_).Split("`t")[1] } > EST.geojson

@mrisney
Copy link

mrisney commented Jan 2, 2023

Trying to convert this to geoparquet file, https://github.com/tschaub/gpq

zipgrep -i "type" Europe-Full.zip | cut -f2 > europe.geojson
and then
./gpq convert europe.geojson europe.parquet, but having issues.

@krassakis
Copy link

#PowerShell

# 1) get the data
curl.exe -O https://usaminedroads.blob.core.windows.net/road-detections/Europe-Full.zip

# 2) extract the records for Estonia, second column of tsv only
Expand-Archive Europe-Full.zip
Select-String -Path Europe-Full\Europe-Full.tsv -Pattern 'EST' -CaseSensitive |  ForEach-Object { ([string]$_).Split("`t")[1] } > EST.geojson

Dear Kirken, i have extracted road network from Greece, but i cant load it in QGIS. I believe that the derived geojson file is not valid. Do you have a solution ? Thank you very much and a happy new year.

@kirkeN
Copy link

kirkeN commented Jan 3, 2023

Yep, it produces Newline-delimited GeoJSON
Try this:

  1. extract the records for Estonia, second column of tsv only
> $output1 = "{ ""type"": ""FeatureCollection"", ""features"": ["
> $output2 = Select-String -Path Europe-Full.tsv -Pattern 'EST' -CaseSensitive | ForEach-Object { ([string]$_).Split("`t")[1] +","}
> $output3 = "]}"
> $output1 + $output2 + $output3 | Out-File  EST.geojson -NoNewline

NB: you have to delete manually the very last comma at the end of the file before the closing "]}" (or enhance the script)

you can check the result here: https://geojson.io/
it also says if there are any syntax errors and what they are. If you succeed there but still cannot open or convert it in QGIS, then download / save GEOJSON file from there and try to open / covert that one.

@JamshidSod
Copy link

when running the following code ogr2ogr -f GPKG Oceania_AUS.gpkg AUS.geojson
FAILURE:
Unable to open datasource AUS.geojson' with the following drivers. -> FITS'
-> PCIDSK' -> netCDF'
-> PDS4' -> VICAR'
-> JP2OpenJPEG' -> PDF'
-> MBTiles' -> BAG'
-> EEDA' -> OGCAPI'
-> ESRI Shapefile' -> MapInfo File'
-> UK .NTF' -> LVBAG'
-> OGR_SDTS' -> S57'
-> DGN' -> OGR_VRT'
-> Memory' -> CSV'
-> NAS' -> GML'
-> GPX' -> KML'
-> GeoJSON' -> GeoJSONSeq'
-> ESRIJSON' -> TopoJSON'
-> Interlis 1' -> Interlis 2'
-> OGR_GMT' -> GPKG'
-> SQLite' -> ODBC'
-> WAsP' -> PGeo'
-> MSSQLSpatial' -> PostgreSQL'
-> OpenFileGDB' -> DXF'
-> CAD' -> FlatGeobuf'
-> Geoconcept' -> GeoRSS'
-> VFK' -> PGDUMP'
-> OSM' -> GPSBabel'
-> OGR_PDS' -> WFS'
-> OAPIF' -> EDIGEO'
-> SVG' -> Idrisi'
-> XLS' -> ODS'
-> XLSX' -> Elasticsearch'
-> Carto' -> AmigoCloud'
-> SXF' -> Selafin'
-> JML' -> PLSCENES'
-> CSW' -> VDV'
-> GMLAS' -> MVT'
-> NGW' -> MapML'
-> Parquet' -> Arrow'
-> TIGER' -> AVCBin'
-> AVCE00' -> HTTP'
Could you please help with that?

@JamshidSod
Copy link

AUS.geojson file has only text: Binary file Oceania-Full.zip matches

@mykol404
Copy link

How would I run this to convert a full dataset (such as South America) without extracting a country? I played around with the command and cannot figure it out. Any help would be tremendously appreciated!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment