1

for each value of parcel no: in http://www.ma-investment.gov.bh/bps_ppd_en/ the map generates polygons.

I want to extract xy values corresponding to polygon shapes which i can convert to longitude,latitude using gpoint.php

  • 3
    The polygons are being drawn directly on a tile, look in the network tab of developer tools in your browser or see this link. So, you will not being able to scrape them directly, as they are not being sent to the client. – John Powell Apr 13 '15 at 6:44
  • Welcome to GIS SE. Please edit some extra info into the body of the question for clarification: e.g. Give us a valid parcel no (& block no?) so we can even generate what you describe? – Martin F Apr 13 '15 at 18:27
  • @JohnBarça it looks like you could post your comment as an answer. – PolyGeo Apr 19 '15 at 5:27
  • 1
    @PolyGeo. OK, as suggested, with a bit more detail. – John Powell Apr 20 '15 at 8:52
3

If you look at what is coming back from the server, by looking at the Network tab of Developer Tools, eg, in Chrome or Firefox, CTRLSHIFTI, then choose Network Tab, you will see a URL such as the following, http://www.ma-investment.gov.bh/bps_ppd_en/ESRI.ArcGIS.ADF.Web.MimeImage.ashx?ImgID=39a0cec7-30f8-4291-8dce-1b2509b2fe62&CacheTime=1&kc=1 resulting in an image, as below.

What this means is that the polygons are being drawn directly onto the backdrop mapping server-side, and a WMS image is being sent back. Therefore, there is no direct way of scraping the underlying polygon data, as it is never sent to the server. You could use some kind of image processing tool to extract all the pixels of a given color and then reconvert to vectors, though this would be non-trivial, depending on the output scales you are interested in.

Bahrain Image

  • Hmm, that image processing suggestion has piqued my own interest. Do you have an example/tutorial of someone doing just that? – Richard Law Apr 20 '15 at 9:00
  • 1
    @alpha-beta-soup. There are lots of potential ways. I had to do this recently and I used Postgis (but then I use Postgis for most things). raster2pgsql to load the rasters and then used ST_DumpAsPolygons to convert each distinct set of pixel values to a geometry. You could use a 2nd ST_Union if you wanted to combine various raster attributes values into the same output vector. – John Powell Apr 20 '15 at 9:36
  • I'd be alright with the image processing. I'm less clear on how I'd actually obtain many images from a WMS, including information about their scale. – Richard Law Apr 20 '15 at 9:44
  • @alpha-beta-soup. Ah, ok, well, you can get the implied scale from the geographic vs pixel extents in the WMS request (more or less, as screen to real world scale is a bit of a slippery concept). You would have to write something to pull a bunch of WMS requests covering a grid at the smallest scale you wanted, save to image and then vectorize those using raster2pgsql plus ST_DumpAsPolygons or some other method. Once it is vectorized, you could then produce any scale you wanted -- thinking about it a bit more. – John Powell Apr 20 '15 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.