How to see envelope in qgis? - qgis

I am using JTS library functions to get an envelope around lat,long.
Now I have the envelope but I can't find an option in qgis to enter the coordinates of an envelope and see if correct BBox is created or not.
Env[ this.minx : this.maxx, this.miny : this.maxy ]
Env[-50004.9793102 : 49995.0206898, -49963.5205293 : 50036.4794707]
I should see the bbox drawn on the osm layer.

An easy way is to print your geometry in WKT format then copy/paste the string into QGIS.
Steps
Suppose you've got an Envelope instance using JTS.
The following code will convert your Envelope instance to Geometry, so that it can be printed in WKT format.
Envelope yourEnvelope;
final GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
System.out.println(geometryFactory.toGeometry(yourEnvelope));
You will get a string looks like:
POLYGON ((1.2 9.5, 1.2 8.1, 4.7 8.1, 4.7 9.5, 1.2 9.5))
Install QGIS plugin QuickWKT
Paste your string into QuickWKT
You got your bounding box drawn in QGIS.

Related

leaflet shp-write to convert geojson to shapefile

I'm trying to convert a Geojson to a zipped shapefile using shp-write.
But when I follow the example given on the GitHub page https://github.com/mapbox/shp-write#example
I'm getting a "ReferenceError: require is not defined" error on this line:
var shpwrite = require('shp-write');
This question was posted at Converting Geojson to Shapefile in Javascript using shp-write, but I was unable to access the updated file at https://jsfiddle.net/rajkishan16/3xff9zmy/
Can someone help me?
Thanks.

mapbox-gl. Points with same location show as regular polygon

So for 2 points:
O-O
for 3 poins:
O
/ \
O O
etc.
For example I have 2 points with the same location. They overlap. I want to offset those markers and connect them with lines like in the image below:
Here I've found something but don't know if it applies here how to customise cluster icon in mapbox-gl?
I found something similar for carto https://carto.com/blog/stacking-chips-a-map-hack/
#rofrol, basically you can use a technique called "Spiderifier" to do it.
Here is the library for using in all framework
https://www.npmjs.com/package/mapboxgl-spiderifier
If you're using ReactJS, here is another solution
https://www.npmjs.com/package/react-mapbox-gl-spiderifier

QGIS - eliminate srs from BBOX?

I'm trying to render an ArcGIS WFS service within QGIS. Through no fault of QGIS, the service is failing because of the 5th BBOX parameter (urn:ogc:def:crs:EPSG::4326):
https://canttouchthis/arcgis/services/CALIX_TEST/CALIX_ANNOTATIONS/MapServer/WFSServer?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=CALIX_TEST_CALIX_ANNOTATIONS:polygons&SRSNAME=urn:ogc:def:crs:EPSG::4326&BBOX=4324959.29130463115870953,-12827075.77402532286942005,4325046.08483351208269596,-12826893.6371572520583868,urn:ogc:def:crs:EPSG::4326 - server replied: Bad Request
When I remove ,urn:ogc:def:crs:EPSG::4326 it works fine -- ESRI WFS isn't equipped to deal with it:
<![CDATA[
KVP parser : parameter 'bbox' '4324959.29130463115870953,-12827075.77402532286942005,4325046.08483351208269596,-12826893.6371572520583868,urn:ogc:def:crs:EPSG::432' not recognized.
]]>
Once I remove the 5th parameter I get the desired feature data.
QUESTION: Can QGIS be configured to NOT provide the srs in the bbox?
ANSWER: Supply a filter (e.g. 1=1).
At this time, QGIS cannot be configured to suppress the 5th BBOX parameter but if you supply a dummy filter (e.g. 1=1) it forces QGIS to use a POST instead of a GET. This will eliminate the incompatible BBOX allowing you to view ESRI features within QGIS via WFS services.

How can I parse *.vector.pbf about Mapbox vector tile map?

*.pbf("Protocolbuffer Binary Format") is primarily intended as an alternative to the XML format.
There are two formats of *.osm.pbf and *.vector.pbf. What tools can I use to open these files? (I know JOSM can open *.osm.pbf files, but it can't open *.vector.pbf files.)
If I want to write own *.vector.pbf files in Mapbox, how do I work for that?
Thanks!
Regarding question #2, extracting PBF data
Using GDAL's ogr2ogr is the easiest method (I found).
Given a file named 1583.vector.pbf decode it to a, for example, shapefile (folder) named output:
# cmd show prog. output format output name input name
ogr2ogr -progress -f "ESRI Shapefile" output 1583.vector.pbf
Regarding question #3, creating PBF data
Use the same command as above but swap the input/outputs and output format:
# example source: https://gdal.org/drivers/vector/mvt.html
ogr2ogr -f MVT mytileset source.gpkg -dsco MAXZOOM=10
The Vector tiles used by Mapbox are serialized as Protocol Buffers.
Protocol Buffers allow you to efficiently compress the vector data inside the tile.
The Mapbox Tile Specification is available on github.
Esri has also adopted the same specification for their products.
You can find a list of parsers, renderers & CLI utilities here: https://github.com/mapbox/awesome-vector-tiles
In the common scenario, you can use mapbox-gl-js to render the vector tiles on the client. To generate vector tiles, you can use Mapbox Studio. This will require uploading your data online in the Studio. You can also use Mapbox Studio Classic (the older version) to generate the tiles locally.
Internally, Mapbox Studio uses the tilelive API, so you can programatically generate the tiles. In the list above there are other good alternatives as well.

Use OSM Map in SUMO

I want to export a Munich map from OSM for SUMO Simulator. I've managed to download such a map from bbbike.de(472MB), but when I'm converting it to .net.xml with netconvert I'm getting a lot of warnnings and the simulator cannot import the map ("Loading error"). Do you have any idea how can I convert correctly the map (or do you think it is because the big volume of the file?), or where could I get such a map(in a properly sumo format = xml, I acctualy need just the highways, I've tried to select just highways with osmosis but I have the same problem in the end)?
Ok to summarize our experience and to close this question :)
SUMO has problems with parsing big full OSM files. So you need to cut the area and filter for highways with osmosis:
Get the state of bavaria or of the surrounding http://download.geofabrik.de/europe/germany/bayern/oberbayern.html
osmosis --read-pbf ./oberbayern-latest.osm.pbf --bounding-box top=48.3298 left=11.2699 bottom=48.0460 right=11.8948 --write-xml ./munich.xml
osmosis --read-xml ./munich.xml --tf accept-ways highway=* --used-node --write-xml ./munich_streets.xml
This can be loaded to SUMO, esp. with the eWorld GUI.