[GeoNode-devel] Programmatically create layers and maps from own Django App

EFTAS Carsten Stemmler carsten.stemmler at eftas.com
Wed Sep 11 08:06:03 PDT 2019


Hello Toni,

thank you for your help, this was already quite useful.
Maybe you can also help with a follow-up question:

I created a new map using the way you pointed out and the map is visible in the Geonode maps overview.
But when I try to view the map, the layers are unfortunately not visible to the user (who created the map). All layers are also owned by the same user.
To check for general errors on the system, I created a map manually with the same layers using the Mapstore GUI and this map is displayed without a problem.
I was unfortunately also not able to spot any error messages on the server or client, which hint to a problem with the map.

Any hints are appreciated,
Carsten

--
Carsten Stemmler
- Research & Development

E F T A S    Fernerkundung
Technologietransfer GmbH
Oststraße 2-18
48145 Münster
Fon: +49 251 13307-0      E-Mail: carsten.stemmler at eftas.com
Fax: +49 251 13307-33     Web:   http://www.eftas.com
Geschäftsführer:
Dipl.-Ing. Georg Altrogge

Sitz der Gesellschaft: Münster
Amtsgericht Münster, HRB 2999
USt.-IdNr. DE 126038986
________________________________
Von: Toni Schönbuchner [toni.schoenbuchner at csgis.de]
Gesendet: Montag, 9. September 2019 20:14
An: EFTAS Carsten Stemmler
Cc: geonode-devel-owner at lists.osgeo.org
Betreff: Re: Programmatically create layers and maps from own Django App

Hi Carsten,

in case you have generated files on your disk maybe it could be enough to just use importlayers?
Have a look how it's done here: https://github.com/GeoNode/geonode/blob/master/pavement.py#L1002

For map creation I would go with something like:

$ python manage.py shell

from geonode.layers.models import Layer
from geonode.maps.models import Map
from geonode.people.models import Profile

user = Profile.objects.get(id=1000)
m = Map()
layer_name = Layer.objects.all().first().alternate
m.create_from_layer_list(user, [layer_name], "title", "abstract")


In this case 1000 is the ID of my admin user. You would pass your newly imported layers to
m.create_from_layer_list()

cheers,

Toni


Am 09.09.2019 um 12:13 schrieb geonode-devel-owner at lists.osgeo.org<mailto:geonode-devel-owner at lists.osgeo.org>:

As list administrator, your authorization is requested for the
following mailing list posting:

   List:    geonode-devel at lists.osgeo.org<mailto:geonode-devel at lists.osgeo.org>
   From:    carsten.stemmler at eftas.com<mailto:carsten.stemmler at eftas.com>
   Subject: Programmatically create layers and maps from own Django App
   Reason:  Post to moderated list

At your convenience, visit:

   https://lists.osgeo.org/mailman/admindb/geonode-devel

to approve or deny the request.

Von: EFTAS Carsten Stemmler <carsten.stemmler at eftas.com<mailto:carsten.stemmler at eftas.com>>
Betreff: Programmatically create layers and maps from own Django App
Datum: 9. September 2019 um 11:39:39 MESZ
An: "geonode-devel at lists.osgeo.org<mailto:geonode-devel at lists.osgeo.org>" <geonode-devel at lists.osgeo.org<mailto:geonode-devel at lists.osgeo.org>>


Dear all,

I created a new Django App by using geonode-project (Geonode version 2.10) to do some geospatial processing.
As a result of this process I want to create a new layer (and furthermore a map) within Geonode without user interaction.

I already had a look at the documentation, however I'm not sure about the right way to accomplish this task. Can I use internal functions e.g. from geonode.layers.models or is it necessary to use the Geoserver Rest API to import the data there directly (or another way I am not aware of at the moment)?

Any hints and also specific links to the documentation are appreciated.
Carsten

--
Carsten Stemmler
- Research & Development

E F T A S    Fernerkundung
Technologietransfer GmbH
Oststraße 2-18
48145 Münster
Fon: +49 251 13307-0      E-Mail: carsten.stemmler at eftas.com<mailto:carsten.stemmler at eftas.com>
Fax: +49 251 13307-33     Web:   http://www.eftas.com<http://www.eftas.com/>
Geschäftsführer:
Dipl.-Ing. Georg Altrogge

Sitz der Gesellschaft: Münster
Amtsgericht Münster, HRB 2999
USt.-IdNr. DE 126038986



Von: geonode-devel-request at lists.osgeo.org<mailto:geonode-devel-request at lists.osgeo.org>
Betreff: confirm 61cb4ec0107fc608b6f30c51a47cea3e31831aea
Datum: 9. September 2019 um 12:13:03 MESZ


If you reply to this message, keeping the Subject: header intact,
Mailman will discard the held message.  Do this if the message is
spam.  If you reply to this message and include an Approved: header
with the list password in it, the message will be approved for posting
to the list.  The Approved: header can also appear in the first line
of the body of the reply.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-devel/attachments/20190911/dd39c5bb/attachment-0001.html>


More information about the geonode-devel mailing list