Permalink
Browse files

added working map extractor

  • Loading branch information...
jonnyhuck committed Nov 9, 2017
1 parent 5186cc5 commit cdb082408f90a375cea8d114f0db4d344f50f32e
BIN +2.12 MB Leh.png
Binary file not shown.
@@ -27,7 +27,7 @@ You will then need to change the end of **line 407** of the resulting **style.xm
.../10m-populated-places-simple/10m-populated-places-simple.shp",
```
If you want the Blossom version of the style, then follow the simple instructions [here](https://github.com/stekhn/blossom), then compile the .mml project into a .xml Mapnik Spreadsheet using [carto](https://github.com/mapbox/carto):
If you want the Blossom version of the style, then follow the simple instructions [here](https://github.com/stekhn/blossom), then compile the .mml project into a .xml Mapnik Stylesheet using [carto](https://github.com/mapbox/carto):
```sh
carto OSMBright/project.mml > OSMBright/style.xml
@@ -43,10 +43,22 @@ python mapgen.py -a -253416.76422779588028789 -b 7076444.70266312919557095 -c -2
would give:
![out.png](images/out.png)
![example Paper2GIS map](images/out.png)
`python mapgen.py -h` will give further information for now.
## Map Extractor
### Setup
### Running
To extract data from an image, simply take a photograph of it like this (leave plenty of border around the page):
![example of marked up image](images/photo.jpg)
You can then extract the markup to a GeoTiff using:
`python mapex.py -r reference.png -m ref_map.png -t photograph.jpg -k 5`
Here is the result:
![resulting geotiff](images/diff.png)
`python mapex.py -h` will give further information for now.
@@ -62,8 +62,8 @@
print "I can see", len(contours), "bubbles, with a mass of", ds_mass
# switch back to BGR and draw contours
crop_img = cv2.cvtColor(crop_img,cv2.COLOR_GRAY2BGR)
cv2.drawContours(crop_img, questionCnts, -1, (0,255,0), 2)
# crop_img = cv2.cvtColor(crop_img,cv2.COLOR_GRAY2BGR)
# cv2.drawContours(crop_img, questionCnts, -1, (0,255,0), 2)
# show the result
# cv2.imshow("cropped", crop_img)
BIN +2.17 KB diff.png
Binary file not shown.
@@ -0,0 +1,191 @@
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis projectname="" version="2.18.2">
<title></title>
<autotransaction active="0"/>
<evaluateDefaultValues active="0"/>
<layer-tree-group expanded="1" checked="Qt::Checked" name="">
<customproperties/>
<layer-tree-layer expanded="1" checked="Qt::Checked" id="OpenStreetMap20170810172542922" name="OpenStreetMap">
<customproperties/>
</layer-tree-layer>
</layer-tree-group>
<relations/>
<mapcanvas>
<units>meters</units>
<extent>
<xmin>-669311.24244234326761216</xmin>
<ymin>7272908.96144956443458796</ymin>
<xmax>-649693.77531244151759893</xmax>
<ymax>7292526.42857946548610926</ymax>
</extent>
<rotation>0</rotation>
<projections>1</projections>
<destinationsrs>
<spatialrefsys>
<proj4>+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs</proj4>
<srsid>3857</srsid>
<srid>3857</srid>
<authid>EPSG:3857</authid>
<description>WGS 84 / Pseudo Mercator</description>
<projectionacronym>merc</projectionacronym>
<ellipsoidacronym>WGS84</ellipsoidacronym>
<geographicflag>false</geographicflag>
</spatialrefsys>
</destinationsrs>
<rendermaptile>0</rendermaptile>
<layer_coordinate_transform_info>
<layer_coordinate_transform destAuthId="EPSG:3857" srcAuthId="EPSG:3857" srcDatumTransform="-1" destDatumTransform="-1" layerid="OpenStreetMap20170810172542922"/>
</layer_coordinate_transform_info>
</mapcanvas>
<layer-tree-canvas>
<custom-order enabled="0">
<item>OpenStreetMap20170810172542922</item>
</custom-order>
</layer-tree-canvas>
<legend updateDrawingOrder="true">
<legendlayer drawingOrder="-1" open="true" checked="Qt::Checked" name="OpenStreetMap" showFeatureCount="0">
<filegroup open="true" hidden="false">
<legendlayerfile isInOverview="0" layerid="OpenStreetMap20170810172542922" visible="1"/>
</filegroup>
</legendlayer>
</legend>
<Composer title="Composer 1" visible="1">
<Composition resizeToContentsMarginLeft="0" snapping="0" showPages="1" guidesVisible="1" resizeToContentsMarginTop="0" worldFileMap="{932f4842-74e9-4bc9-b008-be49aa6eae35}" alignmentSnap="1" printResolution="300" paperWidth="297" gridVisible="0" snapGridOffsetX="0" smartGuides="1" snapGridOffsetY="0" resizeToContentsMarginRight="0" snapTolerancePixels="5" printAsRaster="0" generateWorldFile="0" paperHeight="210" numPages="1" snapGridResolution="10" resizeToContentsMarginBottom="0">
<symbol alpha="1" clip_to_extent="1" type="fill" name="">
<layer pass="0" class="SimpleFill" locked="0">
<prop k="border_width_map_unit_scale" v="0,0,0,0,0,0"/>
<prop k="color" v="255,255,255,255"/>
<prop k="joinstyle" v="miter"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0,0,0,0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="no"/>
<prop k="outline_width" v="0.26"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="style" v="solid"/>
</layer>
</symbol>
<ComposerMap followPreset="false" mapRotation="0" keepLayerSet="false" followPresetName="" id="0" previewMode="Cache" drawCanvasItems="true">
<Extent ymin="7275876" xmin="-674839.23899999994318932" ymax="7292176" xmax="-646139.23899999994318932"/>
<LayerSet/>
<Grid/>
<AtlasMap scalingMode="2" atlasDriven="0" margin="0.10000000000000001"/>
<ComposerItem pagey="5" page="1" id="" lastValidViewScaleFactor="2.61264" positionMode="0" positionLock="false" x="5" y="5" visibility="1" zValue="2" background="true" transparency="0" frameJoinStyle="miter" blendMode="0" width="287" outlineWidth="0.3" excludeFromExports="0" uuid="{932f4842-74e9-4bc9-b008-be49aa6eae35}" height="163" itemRotation="0" frame="false" pagex="5">
<FrameColor alpha="255" red="0" blue="0" green="0"/>
<BackgroundColor alpha="255" red="255" blue="255" green="255"/>
<customproperties/>
</ComposerItem>
</ComposerMap>
<customproperties/>
</Composition>
</Composer>
<projectlayers>
<maplayer minimumScale="0" maximumScale="1e+08" type="raster" hasScaleBasedVisibilityFlag="0">
<extent>
<xmin>-20037508.33999999985098839</xmin>
<ymin>-20037508.33999999985098839</ymin>
<xmax>20037508.33999999985098839</xmax>
<ymax>20037508.33999999985098839</ymax>
</extent>
<id>OpenStreetMap20170810172542922</id>
<datasource>&lt;GDAL_WMS>
&lt;Service name="TMS">
&lt;ServerUrl>http://tile.openstreetmap.org/${z}/${x}/${y}.png&lt;/ServerUrl>
&lt;/Service>
&lt;DataWindow>
&lt;UpperLeftX>-20037508.34&lt;/UpperLeftX>
&lt;UpperLeftY>20037508.34&lt;/UpperLeftY>
&lt;LowerRightX>20037508.34&lt;/LowerRightX>
&lt;LowerRightY>-20037508.34&lt;/LowerRightY>
&lt;TileLevel>19&lt;/TileLevel>
&lt;TileCountX>1&lt;/TileCountX>
&lt;TileCountY>1&lt;/TileCountY>
&lt;YOrigin>top&lt;/YOrigin>
&lt;/DataWindow>
&lt;Projection>EPSG:3857&lt;/Projection>
&lt;BlockSizeX>256&lt;/BlockSizeX>
&lt;BlockSizeY>256&lt;/BlockSizeY>
&lt;BandsCount>3&lt;/BandsCount>
&lt;Cache />
&lt;/GDAL_WMS>
</datasource>
<keywordList>
<value></value>
</keywordList>
<layername>OpenStreetMap</layername>
<srs>
<spatialrefsys>
<proj4>+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs</proj4>
<srsid>3857</srsid>
<srid>3857</srid>
<authid>EPSG:3857</authid>
<description>WGS 84 / Pseudo Mercator</description>
<projectionacronym>merc</projectionacronym>
<ellipsoidacronym>WGS84</ellipsoidacronym>
<geographicflag>false</geographicflag>
</spatialrefsys>
</srs>
<customproperties>
<property key="identify/format" value="Value"/>
<property key="ol_layer_type" value="OpenStreetMap"/>
</customproperties>
<provider>gdal</provider>
<noData>
<noDataList bandNo="1" useSrcNoData="0"/>
<noDataList bandNo="2" useSrcNoData="0"/>
<noDataList bandNo="3" useSrcNoData="0"/>
</noData>
<map-layer-style-manager current="">
<map-layer-style name=""/>
</map-layer-style-manager>
<pipe>
<rasterrenderer opacity="1" alphaBand="-1" blueBand="3" greenBand="2" type="multibandcolor" redBand="1">
<rasterTransparency/>
</rasterrenderer>
<brightnesscontrast brightness="0" contrast="0"/>
<huesaturation colorizeGreen="128" colorizeOn="0" colorizeRed="255" colorizeBlue="128" grayscaleMode="0" saturation="0" colorizeStrength="100"/>
<rasterresampler maxOversampling="2"/>
</pipe>
<blendMode>0</blendMode>
</maplayer>
</projectlayers>
<properties>
<Measurement>
<DistanceUnits type="QString">meters</DistanceUnits>
<AreaUnits type="QString">m2</AreaUnits>
</Measurement>
<SpatialRefSys>
<ProjectCRSProj4String type="QString">+proj=longlat +datum=WGS84 +no_defs</ProjectCRSProj4String>
<ProjectCrs type="QString">EPSG:4326</ProjectCrs>
<ProjectCRSID type="int">3452</ProjectCRSID>
<ProjectionsEnabled type="int">1</ProjectionsEnabled>
</SpatialRefSys>
<Paths>
<Absolute type="bool">false</Absolute>
</Paths>
<Gui>
<SelectionColorBluePart type="int">0</SelectionColorBluePart>
<CanvasColorGreenPart type="int">255</CanvasColorGreenPart>
<CanvasColorRedPart type="int">255</CanvasColorRedPart>
<SelectionColorRedPart type="int">255</SelectionColorRedPart>
<SelectionColorAlphaPart type="int">255</SelectionColorAlphaPart>
<SelectionColorGreenPart type="int">255</SelectionColorGreenPart>
<CanvasColorBluePart type="int">255</CanvasColorBluePart>
</Gui>
<Digitizing>
<DefaultSnapToleranceUnit type="int">2</DefaultSnapToleranceUnit>
<SnappingMode type="QString">current_layer</SnappingMode>
<DefaultSnapType type="QString">off</DefaultSnapType>
<DefaultSnapTolerance type="double">0</DefaultSnapTolerance>
</Digitizing>
<PositionPrecision>
<DecimalPlaces type="int">2</DecimalPlaces>
<Automatic type="bool">true</Automatic>
</PositionPrecision>
<Legend>
<filterByMap type="bool">false</filterByMap>
</Legend>
</properties>
<visibility-presets/>
</qgis>
Oops, something went wrong.

0 comments on commit cdb0824

Please sign in to comment.