Do I have to use geojson files to get data when I click polygons on the map in mapbox gl js? - mapbox-gl-js

I have 16,000 rows of data in excel.
In this excel, I have census block numbers.
What I want to achieve is that I want to make a map layer for these block numbers.
Then, if I click a polygon, the information of a block number display on the popups, like which state, county, and so on.
How can I do that? Do I have to use geojson files for this?
Because, many exmaples in the mapbox use geojson.
But I don't have any coordinates for these block numbers and 16,000 rows are really big to me. I got only block numbers.
But I got shapefiles for whole state block numbers.It is too big to upload mapbox gl js.
If geojson file is the way to achieve my goal, can someone tell me the orders that I can follow?
Or is there other way, please advise me.
Thanks.

So you have a geometry file ("shapefiles for whole state block numbers") and a data file ("16,000 rows of data in excel"). You want the user to click on a boundary in the geometry, and see data from the data file. You have two main options:
Join the data and geometry first (eg, use geojson-join, then upload to Mapbox as a tileset.
Upload just the geometry. Load the CSV file when the web page loads, then when the user clicks, display something from the CSV file.

Related

Filtering polygons based on text input in mapbox

I'm trying to work out a variation on the mapbox code provided in this tutorial here: https://docs.mapbox.com/mapbox-gl-js/example/filter-markers-by-input/
But instead of filtering individual points, I'm trying to figure out how to filter polygons from a GeoJSON that have names appended based on an integer feature. Basically, I want to be able to enter the appended name of a polygon into a text box and have the map filter to just that polygon. I'm having difficulty identifying which parts of the code in the example to isolate and graft over. Has anyone tried something like this before?
When you say "filter to just that polygon", I think what you mean (in geospatial terms) is "filter to show only points within that polygon".
You will want to use Turf's "booleanWithin" function.
You will want to change this code:
layerIDs.forEach(function(layerID) {
map.setLayoutProperty(layerID, 'visibility',
layerID.indexOf(value) > -1 ? 'visible' : 'none');
});
You will have to iterate over the points themselves (not just their IDs), and use the booleanWithin function to check whether the point is within the polygon that you have somewhere else loaded.

Dissolve buffer lines with other data QGIS

I have a problem where my buffer lines do not dissolve with the rest of the data. I want the buffer lines to "open" where they cross other data, right now it looks like the buffer data is layered on top of the other data.
In the picture I have pointed out a place where I would like the buffer to "merge" with the rest. There are plenty of those places, I have tried the dissolve but this is the only result I have gotten. Picture of the problem.
What you want to do is dissolve but you will need to dissolve the polygons based on a field from the attribute table. If all of the shapes that you want to merge have the same value in that field of the attribute table you'll be able to utilize dissolve.
Please see this post from gis.stackexchange:
Merge intersecting polygons into one which are part of the same feature

How to convert GeoJSON to vector.pbf (Protobuf)?

I have a big GeoJson file and I need to convert it to the vector format that can be loaded by the Mapbox. I need to have an external file, so I can't use Mapbox Studio for uploading and converting the data.
Currently I found https://github.com/mapbox/tippecanoe tool, but it converts GEoJSON to MBTiles (SQLite format). I think a can't use it for my map. As I can see from all the examples of the Mapbox service - it uses a XXX.vector.pbf (protobuf) format (small and fast). So the question is - how to get a Protobuf vector file from the original GeoJSON ? Thanks!
Tippecanoe is probably the right answer: it generates a ton of .pbf files, and bundles them into a single .mbtiles file. Usually you then pass that .mbtiles file to a vector tile server (there are heaps), or upload it to Mapbox or something.
If you want to explode out the .mbtiles file, you can use mbutil.
Finally, if you want to translate GeoJSON directly into protobuf format (different from the Mapbox vector tile format, I think), you can use GeoBuf.

Multiple maker on the same place with leaflet

I tried to display a lot of marker on a leaflet map. The data of the marker - coordinates, text... - are stored in a text file.
I made a parser who parse the text, put the data in a big array and then i loop on this array to display each marker.
My problem here is that i got many markers - more than 200, and many of them got the same coordinates.
My code loops well but display only the last marker with each coordinates, how can i display them all properly?
After digging the web around i find a solution which seems to pretty fit my issue.
Leaflet allows you to create "markercluster" which can gather marker together.
Here is a live example : http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-realworld.388.html

Extract open street map data for a specific region

I have openstreet data for a specific state. Now I want to extract the data for a city in that city. What sort of tools are available for that?
There are several tools for extracting a region from a file with OpenStreetMap data. Popular options are
Osmosis - see the wiki page's "Example Usage" section for examples of extracting bounding boxes and polygon areas
Osmconvert - see the "Clipping based on Longitude and Latitude" and "Clipping based on a Polygon" sections
In both cases you need to create or obtain a file containing the city's boundary if you want to accurately extract a polygon area.
You could also try the following web site which is very good at extracting information from open street maps it's the xapi
http://overpass-turbo.eu/
I found it to be good and quick and you can define an area to be searched i.e resizing the boundary box and you can export your retrieved data.