unable to visualize my geojson data with leafletjs - leaflet

all files load fine, I have the following lines to load my data
var map = L.map('map').setView([0,0],2);
var countriesLayer = L.geoJSON(test).addTo(map);
I have exported the shape file from qgis to geojson, with the above script
I can view a sample geojson data but not this one. The CRS I'm working with is Adindan, can't tell if that is the issue. but my geojson data loads fine on mapshaper.

Related

How to copy a pbf file with source layer name different?

I am using mapbox to visualise the data but i want to copy a pbf file(already generated by tippecannoe) from one source to another source with a different source layer so that it can be visualised by mapbox.
`
Some of my attempt looks like below
var pbf = new Pbf(fs.readFileSync('4.pbf'));
const tile = new VectorTile(new Pbf(fs.readFileSync('4.pbf')));
const layer_name=Object.keys(tile.layers).join(',');
obj.new_layer_name = obj.layer_name;
delete obj.layer_name;
console.log('Vector source layers found: ', Object.keys(tile.layers).join(','))
I want to either convert this again into pbf format or any other method to copy pbf tiles with different source layer so that it can be visualised by mapbox

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.

Convert mbgl-offline db to mbtiles

I'm trying to implement mapbox offline in my flutter application... until now I'm using the repository https://github.com/mapbox/mapbox-gl-native to get the map but this map comes in format *.db which is a SQLite format.
Now if I want to use that map (in format .db) in flutter I found the package https://github.com/tobrun/flutter-mapbox-gl where it has an instructions for loading the map (.db) ...
Now, that library is so basic .. I can't do more things like put markers or anything else.. that's why I'm trying to use the other library which is more common in fluter and is called 'flutter_map' and it has a way to load offline maps but the problem here is that I need '{x}{y}{z}.png' that's an image format.
Finally my question is: How can I pass from my map (.db) to that format ({x}{y}{z}.png) ??? or maybe ... how to convert (.db) to (*.mbtiles) ?? cause the last one is more common.
Thanks again!
Mapbox offers the Raster Tiles API which will serve map tiles in ({x}{y}{z}.png) format. https://docs.mapbox.com/api/maps/#raster-tiles These images will be satellite imagery though.
Mapbox also offers the Vector Tiles API which serves map tiles in .mvt format.
https://docs.mapbox.com/api/maps/#vector-tiles
Conversion to .mbtiles
You can convert .mvt tiles to geoJSON using this converter.
Use Mapbox Tippecanoe to convert from geoJSON to .mbtiles

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.

TopJSON in JS converted to GeoJSON

I am tinkering with file which has GeoJSON data of states but stored as a variable in JS.
Here is the file http://leafletjs.com/examples/us-states.js
However I am now using Topojson and reading the documentation https://github.com/mbostock/topojson/wiki/API-Reference
topojson.feature(topology, object) converts GeoJSON to Topojson.
However is there a way that I can store the Topojson format in JS format beforehand like I was doing for Geojson and then convert to GeoJSON calling some function?
Any help will be appreciated!
TopoJSON has a server and clientside API. Serverside (commandline) is for turning GeoJSON (and other formats, shp etc) into a smaller format called TopoJSON. Clientside API turns TopoJSON back into GeoJSON.
The TopoJSON client API supports converting TopoJSON objects back into GeoJSON for use in a web browser. This functionality is provided by topojson.js
Ofcourse you can edit TopoJSON files, just as well as you can edit GeoJSON files. They are both subsets of JSON. Javascript Object Notation.
JSON, (canonically pronounced /ˈdʒeɪsən/ jay-sən;[1] sometimes JavaScript Object Notation), is an open standard format that uses human-readable text to transmit data objects consisting of attribute–value pairs. It is the primary data format used for asynchronous browser/server communication (AJAJ), largely replacing XML (used by AJAX).
You can edit Geo just as well as Topo, it's just text.
Server: https://github.com/mbostock/topojson/wiki/API-Reference#server-api
Client: https://github.com/mbostock/topojson/wiki/API-Reference#client-api