Cluster Mapbox based on Administrative Level - mapbox-gl-js

Is it possible to do clustering in mapbox based on administrative level?
Example : we have coordinates for a province and a district. If we click the province, it will zoom in into a bunch of the district and we can see the data from that district such as population density, etc.
If it is possible. can you give me any references?

Related

OSM get all roads for a given US county as a shapefile

I am working on a project where I need to get a shapefile of all roads in a given US county from open streetmap data, add some information to the county roads, then merge the individual county road shape files into a larger single shapefile using qgis.
My current process is to download the state roads map from the OSM repsitory that has my desired counties, and clip the larger state map to my desired county set of roads using qgis. I use the census bureau's county boundary shapefile to determine the boundary of the clip. The problem is that qgis seems to delete small sections of roads at the county boundary and I am unable to merge the "fabric" of the map together because there are gaps in road lines at the county boundary.
As an alternative approach, I have stared to research using the OSM overpass api to query for a set of county roads. If I can query OSM for all roads within a given county and download as a shapefile, should I then be able to merge the individual county road maps into a larger map without gaps and avoid the problem I have with clipping?
Are there any articles that describe the overpass api query for getting roads within a known administrative boundary, like a US county?

Netlogo - agent travels along the link

I am modelling another project concerning the warehouse operations. In this particular instance, I have to visualize the warehouse layout of the storage space. I plan to define a number of links as routes where the agents (forklift truck) can travel along with in the warehouse.
For each link, there is a distance associated with. It’s not the link length as the distance but a distance attributes user defined. If I set a forklift truck driving speed, how do I reflect it accurately in the model with the use of command like fd (or forward) and jump. How do I specify the unit of measure in jump or fd in association with the distance defined in the link to ensure the forklift truck is moving in a correct distance per tick given the speed and distance.
A simple demo would be highly appreciated! Great thanks!

Facebook Audience API - Targeting Audiences using Shapefiles

I know it's possible to target ads geographically based on zip codes and/or the radius around a given coordinate. Is it somehow possible to target ads geographically based on a shapefile (census Canada for example) or do we have to essentially "build" the shapefile using a combination of zip codes and radius inclusions / exclusions?
It seems the only real "shapes" for a target audience is either providing a country, state (or province if in Canada), congressional district and some zipcodes:
Canada province:
Audience Details:
Location - Living In:
Canada: Alberta
Age:
18 - 65+
US Congressional District
Audience Details:
Location - Living In:
United States: Pennsylvania's 1st District (US:PA01)
Age:
18 - 65+
US Zipcode
Audience Details:
Location - Living In:
United States: Beverly Hills (90210) California
Age:
18 - 65+
However, some zipcodes map to a simple point so you need to fallback to a coordinate and radius.
I guess the only way to create an audience for a given polygon is to try and fill its surface with circles, considering those circles have a minimum radius, so it will always be just an approximation.
There are examples of circle-packing around. I repaired an old gist (https://gist.github.com/shashashasha/1020117) to make you a plunkr example.
See this plunker
However, circle packing considers that circles shouldn't overlap each other, so you'll have to figure out another way to achieve the same.

Framework for plotting latitude longitude in a map based on country, state and district depending on the zoom level

I need a framework which takes a set of latitude longitude points and plots on a world map, grouped by country having the count of points as a marker on each country. Grouping here is the count of latitude longitude points in a country.
And as I drill down into a country, the clustering should change to state based one. And the next level, to districts.
Leaflet marker cluster is something very similar to what I have asked for, but the grouping is based on proximity and it doesn't consider country or state boundaries. That is, they are not region aware.
Regionbound.com has tweaked in some code in the leaflet code for making it region aware,
Sample marker definition:
var marker1 = new L.marker([-37.8, 145], {regions: ["Asia-Pac", "Australia", "VIC", "Melbourne"]} );
But the sample code says, every latitude longitude must be defined along with some extra parameter containing place information.
I could get the place information using reverse geocoding, but reverse geocoding every latitude longitude is time consuming right.
Highmaps provided by Highcharts is one another solution, but there, every country has code which should be assigned a value[count of point coordinates belonging to that country].
But all I have is latitude longitude points, no country or state information.
Thus, I need something which takes only a set of latitude longitude and does clustering based on country, state, district depending on the zoom level.
You have 2 separate needs in your questions:
Map your lat/lng coordinates to appropriate administrative areas. E.g. through the reverse geocoding that you mention.
Display "clusters" on those administrative areas depending on zoom level.
As for point 1, you know that lat/lng points do not say by themselves which administrative area(s) they belong to. So "reverse geocoding every latitude longitude" is a mandatory step. Whether time consuming or not depends on the solution you choose to perform this operation.
If I understand correctly, you would like a "framework" that could do that automatically for you. But frameworks are usually data agnostic, and if they do not have data about boundaries of those administrative areas, they cannot help you.
You may rather look for "services" (like the Mapbox Geocoding API that you mention) or software that would already have such data. It is not time consuming if you can program the lookup (or perform "bulk" operations) and if you are not limited by the requests rate and your amount of points to map (which may be the case with Mapbox).
You could very well set up your own application to perform this mapping:
As for the dataset for administrative areas boundaries, you would probably be interested in links in this post: Are there any free administrative boundaries available as shapefiles? If your points are limited to a few countries, it will be easier for you to find the appropriate data source(s).
Once you have that data, many GIS software should be capable of mapping your lat/lng points to the areas they belong to. This would be mainly for a "one-shot" operation, if your set of points do not change much.
A "web-compatible" alternative would be for example to use Leaflet with point in polygon for Leaflet plugin. You would need your boundaries data converted to GeoJSON format first. Again, GIS software should be capable of doing so, or many online services as well (search for "convert geojson" for example).
A server-side solution would avoid having to manage the entire boundaries data through network and in client browser (if you need to perform the mapping dynamically). I am sure many GIS servers are capable of performing this operation, once they are fed with the boundaries data.
For point 2, once you have completed the above step, I think you would have many options available, including those you mention (RegionBound, Highmaps).
Even with standard mapping libraries (Leaflet, OpenLayers 3), you would just need to build your "clusters" (markers on administrative areas with a number saying how many points are in there), like you have to do with Highmaps anyway for example.
Computing the number of "clustered" point is as easy as filtering your points per area name / code. Then switch the clusters to the desired administrative level when the map zoom changes.
So the key is really to determine first to which areas your points belong to (point 1).
Then a small question would rise about where to place the "cluster" marker:
On centroid of the administrative area? You need the coordinates of that centroid from your data source, or a good algorithm to compute it from the boundaries (good luck on that…).
On "center" of the bounding box of the area? Leaflet can easily compute that: from your area vector shape, you would do myShape.getBounds().getCenter().
On barycentre / centroid of the clustered points? This is what Leaflet.markercluster and RegionBound do (do not know for Highmaps).
Good luck!

Make a "Region Pool" based on cities distance

I am building a simple Logistic Simulation with AnyLogic 7.1. I have a group of cities with a Pool for the Trucks. Each city has a different Pool because the number of trucks is based on the city population. I want to make a "Group Pool" based on distance, so I would add the Pools from the selected cities and make a "Region Pool" for that.
The distance that this "Group" will reach must be editable (for example in a variable)
Is that possible to be made with AnyLogic? If yes, please tell me where to start, I have a very begging level. Thank you.