leaflet shp-write to convert geojson to shapefile - leaflet

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.

Related

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

MATLAB: websave function doesn't save the image

I am using the following function to save map from mapquest as a png file as follows
f_name='abc.png';
url='https://www.mapquest.com?center=1.34,103.683'
%other parameters also go through the url.
websave(f_name, url);
Image is saved but it cannot be displayed throwing the following error.
Error using imread>get_format_info (line 543)
Unable to determine the file format.
Error in imread (line 391)
fmt_s = get_format_info(fullname);
Subsequently following line also throws an error.
[M, Mcolor] = imread(filepath);
When image is opened a message is displayed
File format is not supported.
But if its extension is changed for example to html it does try to load the actual web page display.
Any clues will be highly appreciated
Finally I managed to find the way to do this after a little research!
Static APIs are used in this regard and are available with maps like Google, Mapquest etc.
These static APIs convert the web page of map to its respective image, to put an example for Mapquest it can be used using this

unable to visualize my geojson data with leafletjs

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.

How do I find more comprehensive Google Documentation for using its APIs

A lot of the times the Google documentation is incomplete and is missing things like libraries required to import. How do I view a more comprehensive example?
Example: https://cloud.google.com/vision/docs/detecting-faces#vision-face-detection-python
def highlight_faces(image, faces, output_filename):
"""Draws a polygon around the faces, then saves to output_filename.
Args:
image: a file containing the image with the faces.
faces: a list of faces found in the file. This should be in the format
returned by the Vision API.
output_filename: the name of the image file to be created, where the
faces have polygons drawn around them.
"""
im = Image.open(image)
draw = ImageDraw.Draw(im)
for face in faces:
box = [(vertex.x, vertex.y)
for vertex in face.bounding_poly.vertices]
draw.line(box + [box[0]], width=5, fill='#00ff00')
im.save(output_filename)
Missing the PIL import
On many of Google's code examples, there will be a VIEW ON GITHUB button that will take you to a complete working example rather than a snippet. Very useful for finding necessary library imports or just going straight to more code.
When that is missing, sometimes there is a link to the file like this firebase example linking to index.js:

Import Shapefile to Postgres

I am trying to import a shapefile to Postgres using the following:
shp2pgsql c:\location\water_areas.shp water > water.sql
I am receiving the following message:
c:\location\water_areas.shp: shape (.shp) or index file (.shx) can not be opened, will just import attribute data.
Unfortunately I need more than just attribute data. I need the geometry column. Please help. Why won't it open the shapefile for the conversion.
Without any extra information, there's no way to answer your question. The error message is indicating the app is not finding one or more of the file components. Try running the app inside the 'location' directory with a relative path and see if that changes.