예제 #1
0
def getAttributes(shapefile, WFS_URL):
    """
    Given a valid shapefile(WFS Featuretype as returned by getShapefiles), this function will 
    make a request for one feature from the featureType and parse out the attributes that come from
    a namespace not associated with the normal GML schema. There may be a better way to determine 
    which are shapefile dbf attributes, but this should work pretty well.
    """
    wfs = WebFeatureService(WFS_URL, version='1.1.0')
    feature = wfs.getfeature(typename=shapefile, maxfeatures=1, propertyname=None)
    gml = etree.parse(feature)
    gml_root=gml.getroot()
    name_spaces = gml_root.nsmap
    
    attributes = []
    
    for namespace in name_spaces.values():
        if namespace not in ['http://www.opengis.net/wfs',
                             'http://www.w3.org/2001/XMLSchema-instance',
                             'http://www.w3.org/1999/xlink',
                             'http://www.opengis.net/gml',
                             'http://www.opengis.net/ogc',
                             'http://www.opengis.net/ows']:
            custom_namespace = namespace
            
            for element in gml.iter('{'+custom_namespace+'}*'):
                if etree.QName(element).localname not in ['the_geom', 'Shape', shapefile.split(':')[1]]:
                    attributes.append(etree.QName(element).localname)
    return attributes
예제 #2
0
def SOSElement(tag, nsmap=nsmap):
    t = etree.QName(nsmap['sos'], tag)
    return etree.Element(t, nsmap=nsmap)
예제 #3
0
def SWEElement(tag, nsmap=nsmap):
    t = etree.QName(nsmap['swe'], tag)
    return etree.Element(t, nsmap=nsmap)
예제 #4
0
def GMLElement(tag, nsmap=nsmap):
    t = etree.QName(nsmap['gml'], tag)
    return etree.Element(t, nsmap=nsmap)
예제 #5
0
def OMElement(tag, nsmap=nsmap):
    t = etree.QName(nsmap['om'], tag)
    return etree.Element(t, nsmap=nsmap)