Return coordinates transformed to a given projection
        Projection should be a basemap or pyproj projection object or similar
181118
def project(self, projection):
        '''
        
        '''
        x, y = projection(self.lon.decimal_degree, self.lat.decimal_degree)
        return (x, y)
97952
def get_shapely(self):
        
        if self.shapely == None:
            from shapely.geometry import Polygon as shPolygon
            self.shapely = shPolygon(self.points[:, :2]) # z=0 projection!
        return self.shapely
1310374
def ds_cT(ds, x, y, xy_srs=wgs_srs):
    
    #Convert lat/lon to projected srs
    ds_srs = get_ds_srs(ds)
    #If xy_srs is undefined, assume it is the same as ds_srs
    mX = x
    mY = y
    if xy_srs is not None:
        if not ds_srs.IsSame(xy_srs):
            mX, mY, mZ = cT_helper(x, y, 0, xy_srs, ds_srs)
    return mX, mY
42271
def generate_coordinates(options = {})
        key_layer = layers.find { |layer| layer.relevant_data? }
      
        options[:point_distance] = width / (key_layer.points.size - 1).to_f

        coords = []

        #TODO this will likely break with the new hash model
        key_layer.points.each_with_index do |layer, idx|
          sum, objects = points.inject([0, 0]) do |arr, elem|
            if elem.relevant_data?
              arr[0] += elem.points[idx]
              arr[1] += 1
            end
            arr
          end

          average = sum / objects.to_f

          x_coord = options[:point_distance] * idx

          relative_percent = ((average == min_value) ? 0 : ((average - min_value) / (max_value - min_value).to_f))
          y_coord = (height - (height * relative_percent))

          coords << [x_coord, y_coord].join(',')
        end

        return coords
      end
677362
def get_projection(self, axis):
        
        scale = axis.dot(self) / axis.dot(axis)
        return axis * scale
486467
def get(self,coordinate_system):
        
        if coordinate_system == 'DA-DIR' or coordinate_system == 'specimen':
            return self.pars
        elif coordinate_system == 'DA-DIR-GEO' or coordinate_system == 'geographic':
            return self.geopars
        elif coordinate_system == 'DA-DIR-TILT' or coordinate_system == 'tilt-corrected':
            return self.tiltpars
        else:
            print("-E- no such parameters to fetch for " + coordinate_system + " in fit: " + self.name)
            return None
533006
def map(self, coords):
        
        m = np.empty(coords.shape)
        m[:, :3] = (coords[:, :3] * self.scale[np.newaxis, :3] +
                    coords[:, 3:] * self.translate[np.newaxis, :3])
        m[:, 3] = coords[:, 3]
        return m
1342620
def _convert_point(cls, feature):
        """"""
        lon, lat = feature['geometry']['coordinates']
        popup = feature['properties'].get('name', '')
        return cls(lat, lon)
1083191
def _format_lat(self, lat):
        '''  '''
        if self.ppd in [4, 16, 64, 128]:
            return None
        else:
            if lat < 0:
                return map(lambda x: "{0:0>2}"
                           .format(int(np.abs(x))) + 'S', self._map_center('lat', lat))
            else:
                return map(lambda x: "{0:0>2}"
                           .format(int(x)) + 'N', self._map_center('lat', lat))
645986
def getDataMap(self, intype, pos, name, offset = 0):
        
        if intype == "input":
            vector = self.inputs
        elif intype == "target":
            vector = self.targets
        else:
            raise AttributeError("invalid map type '%s'" % intype)
        return vector[pos][offset:offset+self[name].size]
710840
def project_geometry(geometry, source, target):
    """"""

    project = partial(
        pyproj.transform,
        source,
        target
    )

    return transform(project, geometry)
614290
def load_map_coordinates(map_file):
    
    if map_file[-4:] == ".pkl":
        map_data = pickle.load(open(map_file))
        lon = map_data['lon']
        lat = map_data['lat']
    else:
        map_data = Dataset(map_file)
        if "lon" in map_data.variables.keys():
            lon = map_data.variables['lon'][:]
            lat = map_data.variables['lat'][:]
        else:
            lon = map_data.variables["XLONG"][0]
            lat = map_data.variables["XLAT"][0]
    return lon, lat
1310133
function(projection) {
        var p = projection, equals = false;
        if (p) {
            if (!(p instanceof OpenLayers.Projection)) {
                p = new OpenLayers.Projection(p);
            }
            if ((typeof Proj4js == "object") && this.proj.defData && p.proj.defData) {
                equals = this.proj.defData.replace(this.titleRegEx, "") ==
                    p.proj.defData.replace(this.titleRegEx, "");
            } else if (p.getCode) {
                var source = this.getCode(), target = p.getCode();
                equals = source == target ||
                    !!OpenLayers.Projection.transforms[source] &&
                    OpenLayers.Projection.transforms[source][target] ===
                        OpenLayers.Projection.nullTransform;
            }
        }
        return equals;   
    }
675993
def _get_proj4_name(self, projection):
        """"""
        gmap_name = projection.attrs['grid_mapping_name']
        proj = {
            'geostationary': 'geos',
            'lambert_conformal_conic': 'lcc',
            'polar_stereographic': 'stere',
            'mercator': 'merc',
        }.get(gmap_name, gmap_name)
        return proj
647177
function prettifyProjection(
  longitude,
  latitude,
  proj4Projection,
  proj4longlat,
  projectionUnits
) {
  const zone = 1 + Math.floor((longitude + 180) / 6);

  const projection =
    proj4Projection + " +zone=" + zone + (latitude < 0 ? " +south" : "");

  const projPoint = proj4(proj4longlat, projection, [longitude, latitude]);

  return {
    utmZone: zone + (latitude < 0.0 ? "S" : "N"),
    north: projPoint[1].toFixed(2) + projectionUnits,
    east: projPoint[0].toFixed(2) + projectionUnits
  };
}
397779
def projectionpoints(self, pps):
        
        return [pp - np.dot(pp - self.p1, self.normal_vector) * self.normal_vector for pp in pps]
902691
def to_scanner(self, x, y, z):
        
        if self.transform is None:
            raise ValueError("No transform set for MRSData object {}".format(self))

        transformed_point = self.transform * numpy.matrix([x, y, z, 1]).T

        return numpy.squeeze(numpy.asarray(transformed_point))[0:3]