The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Hi Kim,

I am also beginner in the field of machine learning and recommender systems.I have done some web programming but in the book you have used python Djanjo I have no idea about the python web framework.Should I learn the python Django or start reading the book.

Regards,
Ushant Suman
I was coding this application 6 months before I am shifted to a very different track but still I have set the visible false by default when the application is loaded and I bind the visiblity property of the layer through a checkbox in the layer tree.So if I set it true the layer will be loaded and the check box is ticked and the layer would be visibleto the browser.When you publish a layer like WMS service just like this:
new ol.layer.Tile({
source: new ol.source.TileWMS({

url: 'http://localhost:8080/geoserver/NaturalEarth/wms',

params: {STYLES: '','VERSION': '1.1.1', 'LAYERS': 'NaturalEarth:custom_points'}
}),
name: 'points',
visible:false


})
It would publish the layer as image in the browser and editing on data will not be possible.So I was trying to publish the layer stored in postgis as WFS so that editing on raw data can be done from front end.Although,my project demand only the display of data points along with the labels and i done this by publishing the postgis layer as wms and label is displayed by using style level descriptor of geoserver.and I did not do furthur research on that.Anyone published postgis layer as WFS can help me in this regrard
Ok no issues
Hi,

I am trying to view a Postgis layer as WFS from geoserver and I have tried something like this:

source4 =new ol.source.Vector({
loader: function (extent) {
//place here any actions on start loading layer
document.getElementById('laodingcont').innerHTML = "<font color='orange'>start loading.....</font>";
$.ajax('http://localhost:8080/geoserver/NaturalEarth/wfs', {
type: 'GET',
data: {
service: 'WFS',
version: '1.0.0',
request: 'GetFeature',
typename: 'namespace:"NaturalEarth:Wells',
outputFormat: 'application/json',
srsname: 'EPSG:4326',
bbox: extent.join(',') + ',EPSG:4326'
},
success:function(response) {
format = new ol.format.GeoJSON(),
source4.addFeatures(format.readFeatures(response));
document.getElementById('laodingcont').innerHTML = "<font color='green'>finish loading vector layer.</font>";
}

})
},
strategy: ol.loadingstrategy.bbox
});



layer4 = new ol.layer.Vector({
source: source4,
name: 'WFS',
description: 'Test.',
visible: false,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'rgba(0, 0, 255, 1.0)',
width: 2
})
})
});

But I am not able to see anything in the browser.please help.I am also not geeting any error in console.

I have tried to resolve the previous issues with this code:
layers: [
new OpenLayers.Layer.WMS("MANSA",
"http://localhost:8080/geoserver/NaturalEarth/wms", {
layers: "NaturalEarth:Wells",
strategies: [new OpenLayers.Strategy.BBOX()]
}, {
buffer: 0,
visibility: false,
isBaseLayer: false,
geometryName: "geom",
CQL_FILTER: "field = 'MANSA'",
restrictedExtent:[72.4476470947266, 23.3986797332764,
72.6516571044922, 23.6165523529053],
maxResolution: 'auto'

}
),
new OpenLayers.Layer.WMS("LANGANAJ",
"http://localhost:8080/geoserver/NaturalEarth/wms",
{layers: "NaturalEarth:Wells",
strategies: [new OpenLayers.Strategy.BBOX()],
isBaseLayer: false,
geometryName: "geom",
CQL_FILTER: "field = 'LANGHNAJ'",
maxExtent:[72.4476470947266, 23.3986797332764,
72.6516571044922, 23.6165523529053],
maxResolution: 'auto',
numZoomLevels:19
}

)
It seems to be working bt the only problem with the zoom level.Is there any way in Openlayers 2.10 to increase the zoom level beyond 16.
I have a postgis table of around 100 points I have published it using geoserver and for styling I modified the SLD and using GEoEXT for tree panel my code is some thing like this
var mapPanel, tree;

Ext.application({
name: 'Tree',
launch: function() {
// create a map panel with some layers that we will show in our layer tree
// below.
mapPanel = Ext.create('GeoExt.panel.Map', {
border: true,
region: "center",
// we do not want all overlays, to try the OverlayLayerContainer
map: {allOverlays: false},
center: [72.369949, 23.586761],
zoom: 30,
layers: [
new OpenLayers.Layer.WMS("MANSA",
"http://localhost:8080/geoserver/NaturalEarth/wms", {
layers: "NaturalEarth:Wells",
strategies: [new OpenLayers.Strategy.BBOX()]
}, {
buffer: 0,
visibility: false,
isBaseLayer: false,
geometryName: "geom",
CQL_FILTER: "field = 'MANSA'"
}
),
new OpenLayers.Layer.WMS("LANGANAJ",
"http://localhost:8080/geoserver/NaturalEarth/wms",
{layers: "NaturalEarth:Wells",
strategies: [new OpenLayers.Strategy.BBOX()],
isBaseLayer: false,
geometryName: "geom",
CQL_FILTER: "field = 'LANGHNAJ'"
}

)



// create a group layer (with several layers in the "layers" param)
// to show how the LayerParamLoader works

]
});

My points do not spread in the whole frame of browser even after zooming.I dont understand why??please help.It shows only 2 points very close and after zomming there is no display of labels
Hi,

I have a table in postgis which is storing point data of around 500 points of different fields.My plan is to create the layertree in GeoEXT and when the user click on the check box of the layer tree the points pertaining to that field should be displayed in planer UTM projection.

I am using this approach
1)capture the user click
2) pass it as a parameter in php script
3) write stored function in postgresql and convert the geometry in required SRID andwhich output in geojson.
4)parse json in UI and display in web browser.
2 nd approach
1) Make each view for each field points or based on filtering criteria and publish these views in geoserver if possible in UTM projection and display it in client treting each view as WMS source??

Am I thinking in right direction or something else needs to be done.please guide me.


In listing 11.1 I am facing difficulty in understanding the output of the query.Only Brisbane and San Francisco we are able to dissolve boundaries and able to combine in single multi polygon .It is due to only these multipolygons have a sharing bounday common.I am not sure please help??
No its ok.Thanks for the explanation.
Sorry my mistake I should have read readme.txt. thanks regina for your help.
Hi
I am getting the follwing error while executing the ch11 data from sql pane

[ERROR ] 189.0: syntax error, unexpected INTEGER VALUE.

please help
It means that first we are calculating the intersection points between linestring and treating the empty raster as a box and since the intersection is in meters we convert it into equivalent pixel by dividing 1/2.
Hi,

In listing 7.2 I need help in understanding the dimension of output raster How the size of output raster comes to 60pixel wide and 155 pixels height after running the code??
Thanks Regina its working now.
I need help regarding the osm2pgsql command .I am not able to find the binaries in the link given http://wiki.openstreetmap.org/wiki/Osm2pgsql#Binary.How to run this command using Cygwin.please help
Thanks chris
Hi ,

I recently come across a line data of pipeline stored in ArcSDE in Shape Attribute along with X Y it has also M value stored in it.If I export these to shape files will these M-Values will also be exported in .shp??How to print those M values along with X Y using GDAL/OGR??
Hi all,

I have a point shape file containing some wells lat long and a polygon shapefile I want to know the wells lying in the polygon for this I have used SetSpatialFilter and written the script:

import os
import sys
from osgeo import ogr

from ospybook.vectorplotter import VectorPlotter
ds=ogr.Open(r'C:\Python27\Lib\site-packages\well_all'+'.shp',0)
well_lyr=ds.GetLayer(0)

ds1=ogr.Open(r'C:\Python27\Lib\site-packages\tpoly.shp',0)
ml_lyr=ds1.GetLayer(0)
feat = ml_lyr.GetNextFeature()
pl_cl = feat.geometry().Clone()
well_lyr.SetSpatialFilter(ml_cl)
vp = VectorPlotter(False)
vp.plot(well_lyr,'bo')
vp.plot(ml_cl,'blue', hatch='x')

vp.draw()


# close the data source and text file
ds.Destroy()
ds1.Destroy()
It draws the plot Now the users are demanding that they should be able to download the plot in their in local desktop Is there is any external python library to publish vectorplotter in web based envoirnment so that when the users browse both the shape files from the client side and save the plot for the future reference.
Regards,
Ushant Suman
Thanks Chris for such a quick response.it is exactly what I want to print.gr8.
Regards
Ushant
Hi all,

I have a .shp file of some wells lat lon in WGS_84.When I created the map and gives it to the user user said that all the wells are not coming in the print of map.I am trying to found the way that to print the well names of all the four corners stored in the .dbf file in the same folder.I have written the script:

import os
import sys
from osgeo import ogr


f3=ogr.Open(r'C:\\Python27\\Lib\\site-packages\\shapefile\\fname.shp',0)
t= f3.GetLayer(0)
print t.GetExtent()

This will print the bounding box{Minx,MIny,MaxX,MaXY] and return a python tuple but Is there any way to extend the script to print the wellname attribute along with X, Y of those corner wells stored in the .dbf file??
Thanks you very much Dan for your guidance its working now I have to dig out some way for grid display of attributes in UI.

Regards,
Ushant Suman
Yes f1 is the full path of file such c:\users\somefile.zip
f2 s the c:\users\somefile
f3 is the name of file somefile.zip

All three are passed as command line from php and executed as
exec("C:\Python27\python.exe pythonfilename.py $n", $output);

and all the output needs to be send in the php array $output
Hi chris,
First of all I congratulate you for writing and sharing your real time experience in the form of this great book.I have just a small query I am trying to design a web interface which accepts the zipped shape files(.shp,.dbf,.shx and .prj) as a zip file and the user should be able to see all the attribute data is gridular format in a webpage.Iam using php and passing the file path as command line arguments to my python script.My python code is like this :
import os
import sys
from osgeo import ogr
import ospybook as pb
import zipfile
f1=sys.argv[1]--command line from user input
f2=sys.argv[2]
f3=sys.argv[3]
f4=f2.replace('\\','\\\\')
f6=f1.replace('\\','\\\\')
print f6
with zipfile.ZipFile(f6, "r") as z:
z.extractall(f4)
f7=os.path.splitext(f3)[0]
f5=ogr.Open(f4,0)

print f7
sql = '''SELECT * from f7'''
lyr = f5.ExecuteSQL(sql)
pb.print_attributes(lyr,1)
I get the error on f7 is there any way for replacing f7 with the user uploaded file name so that sql query error is removed.

I know the question might go beyond the scope of book but please help me.

Regards,
Ushant Suman