[Geoserver-users] additional attributes in a shapefile

Hello,

I'm new to GeoServer and to GIS in general so please accept my
apologies if my question is not a very good one:

I have a shapefile defining the county boundaries for my state and
have a dataset of counts-per-counties, attributes not found in the
shapefile.

I would like to present these data via WMF/WMS as appropriate with a
styled layer descriptor file which discriminates based on my
counts-per-county attribute. Should I add my attributes to the
shapefile itself, or is there some way I can keep these data external
to the shapefile and have GeoServer do a "join" on them before
presentation?

   michael

Unfortunately there's no way to do an on-the-fly join. We hope to get there, but it's a pretty hard problem. So you'll have to add the attributes to the shapefile yourself.

best regards,

Chris

Michael Heuer wrote:

Hello,

I'm new to GeoServer and to GIS in general so please accept my
apologies if my question is not a very good one:

I have a shapefile defining the county boundaries for my state and
have a dataset of counts-per-counties, attributes not found in the
shapefile.

I would like to present these data via WMF/WMS as appropriate with a
styled layer descriptor file which discriminates based on my
counts-per-county attribute. Should I add my attributes to the
shapefile itself, or is there some way I can keep these data external
to the shapefile and have GeoServer do a "join" on them before
presentation?

   michael

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

!DSPAM:1003,45c390ff48021510810322!

--
Chris Holmes
The Open Planning Project
http://topp.openplans.org

Thanks.

What if my shapefile is imported into a different datasource, say PostGIS?

Then would it be possible to include a calculated column in the
result, or use SQL to do joins to other database tables? Essentially,
something like

SELECT ..., t1.value as value FROM mytable_postgis t0, my_other_table t1 WHERE
     the_geom && <bounding box of the search polygon> -- this is the
spatial index operation
AND intersects(the_geom, <the polygon> ) -- this is the full OGC
spatial operation
AND t0.population > 1000000
AND t0.some_primary_key = t1.primary_key;

   michael

On 2/2/07, Chris Holmes <cholmes@anonymised.com> wrote:

Unfortunately there's no way to do an on-the-fly join. We hope to get
there, but it's a pretty hard problem. So you'll have to add the
attributes to the shapefile yourself.

best regards,

Chris

Michael Heuer wrote:
> Hello,
>
> I'm new to GeoServer and to GIS in general so please accept my
> apologies if my question is not a very good one:
>
> I have a shapefile defining the county boundaries for my state and
> have a dataset of counts-per-counties, attributes not found in the
> shapefile.
>
> I would like to present these data via WMF/WMS as appropriate with a
> styled layer descriptor file which discriminates based on my
> counts-per-county attribute. Should I add my attributes to the
> shapefile itself, or is there some way I can keep these data external
> to the shapefile and have GeoServer do a "join" on them before
> presentation?
>
> michael
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier.
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Geoserver-users mailing list
> Geoserver-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>
> !DSPAM:1003,45c390ff48021510810322!
>

--
Chris Holmes
The Open Planning Project
http://topp.openplans.org

On 2/2/07, Michael Heuer <heuermh@anonymised.com> wrote:

Thanks.

What if my shapefile is imported into a different datasource, say PostGIS?

Then would it be possible to include a calculated column in the
result, or use SQL to do joins to other database tables?

Yes.

Alex

Alexander Petkov wrote:

On 2/2/07, Michael Heuer <heuermh@anonymised.com> wrote:

Thanks.

What if my shapefile is imported into a different datasource, say PostGIS?

Then would it be possible to include a calculated column in the
result, or use SQL to do joins to other database tables?

Yes.

You do have to register it as a view though in PostGIS (which takes a couple tweaks to work in GeoServer, see http://docs.codehaus.org/display/GEOSDOC/PostGIS+DataStore, or create a new table that has the results of the join.

Chris

Alex

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

!DSPAM:1003,45c3aaf070581775926497!

--
Chris Holmes
The Open Planning Project
http://topp.openplans.org

Hello Chris,

I'm not sure a view gets me where I want.

It's a stretch of an example, but say I had the election results per
county for 10000 races:

table election_result:

candidate_id county_id votes_cast
0 0 100000
1 0 200000
...
9999 100 150000

The query would include candidate_id = ? and the resulting features
should include votes_cast as an attribute so they can be styled
accordingly.

select ..., e.votes_cast from county_postgis c, election_result e
where ...
AND c.county_id = e.county_id

   michael

On 2/2/07, Chris Holmes <cholmes@anonymised.com> wrote:

Alexander Petkov wrote:
> On 2/2/07, Michael Heuer <heuermh@anonymised.com> wrote:
>> Thanks.
>>
>> What if my shapefile is imported into a different datasource, say PostGIS?
>>
>> Then would it be possible to include a calculated column in the
>> result, or use SQL to do joins to other database tables?
>
> Yes.

You do have to register it as a view though in PostGIS (which takes a
couple tweaks to work in GeoServer, see
http://docs.codehaus.org/display/GEOSDOC/PostGIS+DataStore, or create a
new table that has the results of the join.

Chris

>
> Alex
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier.
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Geoserver-users mailing list
> Geoserver-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>
> !DSPAM:1003,45c3aaf070581775926497!
>

--
Chris Holmes
The Open Planning Project
http://topp.openplans.org

Alternatively, as long as I include a primary key as an attribute,
perhaps I can just be clever in generating the style document.

   michael

On 2/2/07, Michael Heuer <heuermh@anonymised.com> wrote:

Hello Chris,

I'm not sure a view gets me where I want.

It's a stretch of an example, but say I had the election results per
county for 10000 races:

table election_result:

candidate_id county_id votes_cast
0 0 100000
1 0 200000
...
9999 100 150000

The query would include candidate_id = ? and the resulting features
should include votes_cast as an attribute so they can be styled
accordingly.

select ..., e.votes_cast from county_postgis c, election_result e
where ...
AND c.county_id = e.county_id

   michael

On 2/2/07, Chris Holmes <cholmes@anonymised.com> wrote:
>
> Alexander Petkov wrote:
> > On 2/2/07, Michael Heuer <heuermh@anonymised.com> wrote:
> >> Thanks.
> >>
> >> What if my shapefile is imported into a different datasource, say PostGIS?
> >>
> >> Then would it be possible to include a calculated column in the
> >> result, or use SQL to do joins to other database tables?
> >
> > Yes.
>
> You do have to register it as a view though in PostGIS (which takes a
> couple tweaks to work in GeoServer, see
> http://docs.codehaus.org/display/GEOSDOC/PostGIS+DataStore, or create a
> new table that has the results of the join.
>
> Chris
>
> >
> > Alex
> >
> > -------------------------------------------------------------------------
> > Using Tomcat but need to do more? Need to support web services, security?
> > Get stuff done quickly with pre-integrated technology to make your job easier.
> > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > _______________________________________________
> > Geoserver-users mailing list
> > Geoserver-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/geoserver-users
> >
> > !DSPAM:1003,45c3aaf070581775926497!
> >
>
> --
> Chris Holmes
> The Open Planning Project
> http://topp.openplans.org
>

I'm pretty sure that anything you can put in a join you can make a view of... Some of the SQL experts on the list can probably give you better advice on how to structure it though.

Chris

Michael Heuer wrote:

Hello Chris,

I'm not sure a view gets me where I want.

It's a stretch of an example, but say I had the election results per
county for 10000 races:

table election_result:

candidate_id county_id votes_cast
0 0 100000
1 0 200000
...
9999 100 150000

The query would include candidate_id = ? and the resulting features
should include votes_cast as an attribute so they can be styled
accordingly.

select ..., e.votes_cast from county_postgis c, election_result e
where ...
AND c.county_id = e.county_id

   michael

On 2/2/07, Chris Holmes <cholmes@anonymised.com> wrote:

Alexander Petkov wrote:

On 2/2/07, Michael Heuer <heuermh@anonymised.com> wrote:

Thanks.

What if my shapefile is imported into a different datasource, say PostGIS?

Then would it be possible to include a calculated column in the
result, or use SQL to do joins to other database tables?

Yes.

You do have to register it as a view though in PostGIS (which takes a
couple tweaks to work in GeoServer, see
http://docs.codehaus.org/display/GEOSDOC/PostGIS+DataStore, or create a
new table that has the results of the join.

Chris

Alex

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Chris Holmes
The Open Planning Project
http://topp.openplans.org

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

!DSPAM:1003,45c3bfef88371194215290!

--
Chris Holmes
The Open Planning Project
http://topp.openplans.org

Michael Heuer ha scritto:

Hello,

I'm new to GeoServer and to GIS in general so please accept my
apologies if my question is not a very good one:

I have a shapefile defining the county boundaries for my state and
have a dataset of counts-per-counties, attributes not found in the
shapefile.

I would like to present these data via WMF/WMS as appropriate with a
styled layer descriptor file which discriminates based on my
counts-per-county attribute. Should I add my attributes to the
shapefile itself, or is there some way I can keep these data external
to the shapefile and have GeoServer do a "join" on them before
presentation?

Taking into consideration the other mails in this thread, I'd suggest:
* load the shapefile and your counts per county information into two
   separate postgis tables
* create a view that joins them and register it against geometry_columns:
   create view county_votes as select * from county join election_result on county.id = election_results.county_id
   insert into geometry columns ... (see the other spatial tables to
   guess the attributes, you have to register the geometric column in
   your view so that Geoserver knows about it, its nature and spatial
   reference system).
* connect the postgis datastore and register the conty_votes view as
   a feature type
* generate on the fly an sld with a filter over the candidate_id you
   want to map, and link the color to the vote number (this sld document
   is going to become big).
* use the generated sld in your WMS requests, putting it in the SLD_BODY
   request field.

That should be (more or less) it.
Cheers
Andrea